#pragma once
#include <iostream>
#include "Comm.hpp"

class Client
{
public:
    Client()
        : _fd(gdefault)
    {}

    bool OpenPipeForwrite()
    {
        _fd = OpenPipe(gForWrite);
        if (_fd < 0) return false;
        return true;
    }

    // std::string * : 输出型参数
    // const std::string & : 输入型参数
    // std::string & : 输入输出型参数
    int SendPipe(std::string &in)
    {
        return ::write(_fd, in.c_str(), in.size());
    }

    void ClosePipe()
    {
        ClosePipeHelper(_fd);
    }

    ~Client()
    {}

private:
    int _fd;
};